package com.sx.gongzhong.pest;

import com.sx.gongzhong.model.CommentBean;
import com.sx.gongzhong.model.HeadParamBean;
import com.sx.gongzhong.model.LegalAdviceBean;
import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.model.BasePageListBean;
import com.sx.gongzhong.net.LegalAdviceManager;
import com.sx.gongzhong.view.LegalAdviceDetailView;

import java.util.Map;

/**法律咨询详情
 * Created by admin on 2018/1/12.
 */

public class LegalAdviceDetailPest {
    private LegalAdviceDetailView legalAdviceDetailView;

    public LegalAdviceDetailPest(LegalAdviceDetailView legalAdviceDetailView) {
        this.legalAdviceDetailView = legalAdviceDetailView;
    }
    //详情
    public void getLegalAdviceDetail(String adviceId) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("adviceId",adviceId);
        new LegalAdviceManager().getLegalAdviceDetail(map, new BaseCallBack<ReplyUserBean.BaseResult<LegalAdviceBean>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<LegalAdviceBean> response) {
                legalAdviceDetailView.getLegalAdviceDetailSuccess(response.data);
            }
            @Override
            public void onFailures(String message) {
                legalAdviceDetailView.showError("获取详情失败");
            }
        });
    }

    //回复列表
    public void getReplayList(String adviceId,int page,int rows) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("dataId",adviceId);
        map.put("page",page);
        map.put("rows",rows);
        new LegalAdviceManager().getReplayList(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<CommentBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<CommentBean>> response) {
                legalAdviceDetailView.getReplayListSuccess(response.data.rows,response.data.total);
            }
            @Override
            public void onFailures(String message) {
                legalAdviceDetailView.showError(message);
            }
        });
    }

    //法律咨询 删除
    public void deleteLegalAdvice(String adviceId) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("ids",adviceId);
        new LegalAdviceManager().deleteLegalAdvice(map, new BaseCallBack<ReplyUserBean.BaseResult<Boolean>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<Boolean> response) {
                legalAdviceDetailView.deleteLegalAdviceSuccess(response.data);
            }
            @Override
            public void onFailures(String message) {
                legalAdviceDetailView.showError(message);
            }
        });
    }
}
